﻿<!--信息通知对象选择树-->
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>选择通知对象</title>
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>  
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>  
        <script src="../../../../Scripts/json2.js" type="text/javascript"></script>  
    }
    <link href="@Url.Content("~/Content/jquery-ui.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/jquery-ui.min.js", true)" type="text/javascript"></script>

    <link href="@Url.Content("~/Scripts/dynatree/skin/ui.dynatree.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/dynatree/jquery.dynatree.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>

    @Html.DevExpress().GetStyleSheets(

    new StyleSheet { ExtensionType = ExtensionType.ListBox, Theme = DevExpressHelper.Theme }
    )
    @Html.DevExpress().GetScripts(
        new Script { ExtensionType = ExtensionType.ListBox }
    )
    <style type="text/css">
        #tree ul.dynatree-container
        {
            overflow: auto;
            position: relative;
            height: 90%;
        }
        #tabs
        {
            overflow: auto;
            position: relative;
            height: 465px;
        }
        body
        {
            margin: 0px;
            font-size: 12px;
        }
    </style>

    <script type="text/javascript">
        var dataDeptEmp = @Html.Raw(Json.Encode(ViewData["deptEmptreeJsonStr"]));
        if (dataDeptEmp!="")
            {
                dataDeptEmp=JSON.parse(dataDeptEmp);
            }
            else
            {
                dataDeptEmp=null;
            }
     var dataWorkGroupEmp = @Html.Raw(Json.Encode(ViewData["workGroupEmptreeJsonStr"]));
        if (dataWorkGroupEmp!="")
            {
                dataWorkGroupEmp=JSON.parse(dataWorkGroupEmp);
            }
            else
            {
                dataWorkGroupEmp=null;
            }
        var selectMode=@ViewData["treeSelectMode"];
    </script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#tabs").css("display", "block");
            $("#tabs").tabs();
            $("#treeDeptEmp").dynatree({
                checkbox: true,
                selectMode: selectMode,
                clickFolderMode: 1,
                children: dataDeptEmp,
                keyboard: false
            });
            $("#treeWorkGroupEmp").dynatree({
                checkbox: true,
                selectMode: selectMode,
                clickFolderMode: 1,
                children: dataWorkGroupEmp,
                keyboard: false
            });
            $("#btnOK").bind("click", function () {
                var allPartsel = new Array();
                var partsel = new Array();
                var selNodes = $("#treeDeptEmp").dynatree("getTree").getSelectedNodes(false);
                $.map(selNodes, function (node) {
                    if (node.data.children == null && node.data.addClass == 'user') {
                        var treeModel = { "Text": "", "Value": "" };
                        var isExists = false;
                        for (var i = 0; i < partsel.length; i++) {
                            if (partsel[i].Value == node.data.key) {
                                isExists = true;
                                break;
                            }
                        }
                        if (isExists == false) {
                            treeModel.Text = node.data.title;
                            treeModel.Value = node.data.key;

                            partsel.push(treeModel);
                        }
                    }

                });
                allPartsel.push(partsel);
                partsel = new Array();
                selNodes = $("#treeWorkGroupEmp").dynatree("getTree").getSelectedNodes(false);
                $.map(selNodes, function (node) {
                    if (node.data.children == null && node.data.addClass == 'user') {
                        var treeModel = { "Text": "", "Value": "" };
                        var isExists = false;
                        for (var i = 0; i < partsel.length; i++) {
                            if (partsel[i].Value == node.data.key) {
                                isExists = true;
                                break;
                            }
                        }
                        if (isExists == false) {
                            treeModel.Text = node.data.title;
                            treeModel.Value = node.data.key;

                            partsel.push(treeModel);
                        }
                    }

                });
                allPartsel.push(partsel);
                window.returnValue = JSON.stringify(allPartsel);
                window.close();
            });
            $("#btnCancel").bind("click", function () {
                window.close();
            });
            var obj = window.dialogArguments;

            if (obj.Value != "") {
                var list = JSON.parse(obj.Value);
                var treeModelList = list[0]; //部门人员
                for (var i = 0; i < treeModelList.length; i++) {
                    $("#treeDeptEmp").dynatree("getTree").selectKey(treeModelList[i].Value);
                }
                treeModelList = list[1]; //工作组人员
                for (var i = 0; i < treeModelList.length; i++) {
                    $("#treeWorkGroupEmp").dynatree("getTree").selectKey(treeModelList[i].Value);
                }
            }
        });

    </script>

</head>
<body>
    <div id="tabs" class="div" style="display: none">
        <ul>
            <li><a href="#DeptEmpTab">部门人员</a></li>
            <li><a href="#WorkGroupEmpTab">工作组人员</a></li>
        </ul>
        <div id="DeptEmpTab">
            <div id="treeDeptEmp">
            </div>
        </div>
        <div id="WorkGroupEmpTab">
            <div id="treeWorkGroupEmp">
            </div>
        </div>
    </div>
    <div style="padding: 0px; background: #efefef; width: 100%; font-size: 12px; text-align: center;">
        <table align="center">
            <tr>
                <td>
                    @Html.DevExpress().Button(settings =>
               {
                   settings.Name = "btnOK";
                   settings.Text = "确定";

                   settings.Images.Image.Url = Url.Content("~/Content/ControlImages/ok.png");

               }).GetHtml()
                </td>
                <td>
                    @Html.DevExpress().Button(settings =>
               {
                   settings.Name = "btnCancel";
                   settings.Text = "取消";

                   settings.Images.Image.Url = Url.Content("~/Content/ControlImages/no.png");
                   settings.CausesValidation = false;

               }).GetHtml()
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
